<?php


namespace app\apiadmin\model\choujiang;


use app\common\utils\Res;
use think\facade\Db;
use think\Model;

class ShuZiRenModel extends Model
{

    protected $name="siyu_shuziren_list";
    

    public static function list()
    {
        return self::field('nick as label,nick as pinyin,id')->select()->toArray();
    }
    public static function getAllChouJiangRobot($param)
    {
        $res_user = Db::name('siyu_prize_shuziren_user')->alias('p')
            ->join('xh_siyu_shuziren_list u','u.id = p.user_id')
            ->where('p.prid',$param['id'])
            ->field('u.nick as label,u.nick as pinyin,u.id')
            ->select()->toArray();
        $selectUserIds = [];
        if($res_user){
            $selectUserIds = array_column($res_user,'id');
        }
        $user_datas = [];
        $user_data = self::field('nick as label,nick as pinyin,id')->select()->toArray();
        if($user_data && $res_user){
            foreach ($user_data as $key=>$value){
                if(!in_array($value['id'],$selectUserIds)){
                    $user_datas[] = $value;
                }
            }
        }
        return $user_datas;
    }
    public static function getEditChouJiangRobot($param)
    {
        $res_user = Db::name('siyu_prize_shuziren_user')->alias('p')
            ->join('xh_siyu_shuziren_list u','u.id = p.user_id')
            ->where('p.prid',$param['id'])
            ->field('u.nick as label,u.nick as pinyin,u.id')
            ->select()->toArray();
        
        return $res_user;
    }
  
}